#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'tian'
__data__ = '2020/4/13 12:20'

from page.housing_rental_page import HousingPage
from conf import settings


class HousingHandled:
    """
    房源租售管理页面的操作
    """

    def __init__(self):
        self.obj = HousingPage()
        self.obj.open_admin_page()
        self.obj.log_background()
        self.entry_page = "住宅出租"
        self.add_succeed = "添加房源成功"

    def residential_rental(self):
        rest_text = self.obj.residence_rental()
        return self.entry_page, rest_text

    def screening_of_city(self):
        """
        筛选城市
        :return:
        """
        flage, city_name, random_city = self.obj.screening_of_city_page()
        random_city = settings.PROPERTY_PARAMETERS.get("locations").get(random_city)
        if flage:
            return True
        else:
            if city_name == random_city:
                return True

    def the_new_housing(self):
        """
        新增住宅出租房源
        :return:
        """
        rest_text = self.obj.add_housing()
        return self.add_succeed, rest_text

    def quit_browser(self):
        self.obj.quit_close_browser()
